<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.10.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>common_util: src/common_util/fileutil.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">common_util
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.10.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_2961cad218251a7c35c6867350b80887.html">common_util</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">fileutil.h File Reference</div></div>
</div><!--header-->
<div class="contents">

<p>The functions and classes about filesystem, such as file and directory operations.  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;string&gt;</code><br />
<code>#include &lt;cstdio&gt;</code><br />
<code>#include &quot;<a class="el" href="filetype_8h_source.html">filetype.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="filepath_8h_source.html">filepath.h</a>&quot;</code><br />
</div>
<p><a href="fileutil_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="nested-classes" name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classcutl_1_1file__guard.html">cutl::file_guard</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">The file guard class to manage the FILE pointer automatically. <a class="el" href="classcutl_1_1file__guard.html" title="The file guard class to manage the FILE pointer automatically. file_guard object can close the FILE p...">file_guard</a> object can close the FILE pointer automatically when his scope is exit.  <a href="classcutl_1_1file__guard.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ab248798acf21f8ce5735738f0882a91b" id="r_ab248798acf21f8ce5735738f0882a91b"><td class="memItemLeft" align="right" valign="top">std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ab248798acf21f8ce5735738f0882a91b">cutl::filetype_flag</a> (<a class="el" href="filetype_8h.html#a9d3ee53b2774c37cc5a17766507de28c">filetype</a> type)</td></tr>
<tr class="memdesc:ab248798acf21f8ce5735738f0882a91b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the file type flag string.  <br /></td></tr>
<tr class="separator:ab248798acf21f8ce5735738f0882a91b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1e27df14bf44381e7e0a20e4c573d4f5" id="r_a1e27df14bf44381e7e0a20e4c573d4f5"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a1e27df14bf44381e7e0a20e4c573d4f5">cutl::createfile</a> (const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;<a class="el" href="filepath_8h.html#abb5a2e2fa6cfd41e8de3515d12a36eb6">path</a>)</td></tr>
<tr class="memdesc:a1e27df14bf44381e7e0a20e4c573d4f5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create a new file.  <br /></td></tr>
<tr class="separator:a1e27df14bf44381e7e0a20e4c573d4f5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a08d521298f87d3470d3163928d3cb1f1" id="r_a08d521298f87d3470d3163928d3cb1f1"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a08d521298f87d3470d3163928d3cb1f1">cutl::createlink</a> (const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;referenece, const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;<a class="el" href="classcutl_1_1filepath.html">filepath</a>)</td></tr>
<tr class="memdesc:a08d521298f87d3470d3163928d3cb1f1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create a symbolic link or shortcut.  <br /></td></tr>
<tr class="separator:a08d521298f87d3470d3163928d3cb1f1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:add3d8ef4215ce8d54c9dbe18dd35c82b" id="r_add3d8ef4215ce8d54c9dbe18dd35c82b"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#add3d8ef4215ce8d54c9dbe18dd35c82b">cutl::createdir</a> (const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;<a class="el" href="filepath_8h.html#abb5a2e2fa6cfd41e8de3515d12a36eb6">path</a>, bool recursive=false)</td></tr>
<tr class="memdesc:add3d8ef4215ce8d54c9dbe18dd35c82b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Create a new directory.  <br /></td></tr>
<tr class="separator:add3d8ef4215ce8d54c9dbe18dd35c82b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab5971fce037518ec1d89532511e84cdf" id="r_ab5971fce037518ec1d89532511e84cdf"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ab5971fce037518ec1d89532511e84cdf">cutl::removefile</a> (const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;<a class="el" href="filepath_8h.html#abb5a2e2fa6cfd41e8de3515d12a36eb6">path</a>)</td></tr>
<tr class="memdesc:ab5971fce037518ec1d89532511e84cdf"><td class="mdescLeft">&#160;</td><td class="mdescRight">Remove a regular file or symbolic link(shortcut on windows).  <br /></td></tr>
<tr class="separator:ab5971fce037518ec1d89532511e84cdf"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a59de688713570479a87f534309f7ec6a" id="r_a59de688713570479a87f534309f7ec6a"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a59de688713570479a87f534309f7ec6a">cutl::removedir</a> (const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;<a class="el" href="filepath_8h.html#abb5a2e2fa6cfd41e8de3515d12a36eb6">path</a>, bool recursive=false)</td></tr>
<tr class="memdesc:a59de688713570479a87f534309f7ec6a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Remove a directory.  <br /></td></tr>
<tr class="separator:a59de688713570479a87f534309f7ec6a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a27c4f2c12172b95c3f64090e431e0393" id="r_a27c4f2c12172b95c3f64090e431e0393"><td class="memItemLeft" align="right" valign="top">std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a27c4f2c12172b95c3f64090e431e0393">cutl::readtext</a> (const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;<a class="el" href="filepath_8h.html#abb5a2e2fa6cfd41e8de3515d12a36eb6">path</a>, uint64_t max_read_size=4096)</td></tr>
<tr class="memdesc:a27c4f2c12172b95c3f64090e431e0393"><td class="mdescLeft">&#160;</td><td class="mdescRight">Read the text content of a file.  <br /></td></tr>
<tr class="separator:a27c4f2c12172b95c3f64090e431e0393"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afce142cfc976c83b8236dfdb2edec314" id="r_afce142cfc976c83b8236dfdb2edec314"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#afce142cfc976c83b8236dfdb2edec314">cutl::writetext</a> (const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;<a class="el" href="filepath_8h.html#abb5a2e2fa6cfd41e8de3515d12a36eb6">path</a>, const std::string &amp;content)</td></tr>
<tr class="memdesc:afce142cfc976c83b8236dfdb2edec314"><td class="mdescLeft">&#160;</td><td class="mdescRight">Write the text content to a file.  <br /></td></tr>
<tr class="separator:afce142cfc976c83b8236dfdb2edec314"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae0b32140037ee8ad3eed3f916aca6121" id="r_ae0b32140037ee8ad3eed3f916aca6121"><td class="memItemLeft" align="right" valign="top">uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ae0b32140037ee8ad3eed3f916aca6121">cutl::filesize</a> (const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;<a class="el" href="classcutl_1_1filepath.html">filepath</a>, bool link_target=false)</td></tr>
<tr class="memdesc:ae0b32140037ee8ad3eed3f916aca6121"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the size of a file.  <br /></td></tr>
<tr class="separator:ae0b32140037ee8ad3eed3f916aca6121"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:add5974dfd24e73d6ea0384d986e03291" id="r_add5974dfd24e73d6ea0384d986e03291"><td class="memItemLeft" align="right" valign="top">uint64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#add5974dfd24e73d6ea0384d986e03291">cutl::dirsize</a> (const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;dirpath)</td></tr>
<tr class="memdesc:add5974dfd24e73d6ea0384d986e03291"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get the size of a directory, include all files and subdirectories.  <br /></td></tr>
<tr class="separator:add5974dfd24e73d6ea0384d986e03291"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa4f744aa8a74118855fab1240f556c50" id="r_aa4f744aa8a74118855fab1240f556c50"><td class="memItemLeft" align="right" valign="top"><a class="el" href="filetype_8h.html#a8827b47b58e5d520b41cb950d8fdea7c">filevec</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aa4f744aa8a74118855fab1240f556c50">cutl::list_files</a> (const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;dirpath, <a class="el" href="filetype_8h.html#a9d3ee53b2774c37cc5a17766507de28c">filetype</a> type=<a class="el" href="filetype_8h.html#a9d3ee53b2774c37cc5a17766507de28ca2f81ea5535f9ec58b162200d3c6a29c6">filetype::all</a>, bool recursive=false)</td></tr>
<tr class="memdesc:aa4f744aa8a74118855fab1240f556c50"><td class="mdescLeft">&#160;</td><td class="mdescRight">List all files in a directory.  <br /></td></tr>
<tr class="separator:aa4f744aa8a74118855fab1240f556c50"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0f3ffa92b4eaffde5de4c0393bf662d3" id="r_a0f3ffa92b4eaffde5de4c0393bf662d3"><td class="memItemLeft" align="right" valign="top"><a class="el" href="filetype_8h.html#a8827b47b58e5d520b41cb950d8fdea7c">filevec</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a0f3ffa92b4eaffde5de4c0393bf662d3">cutl::find_files</a> (const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;dirpath, const std::string &amp;name, bool recursive=false)</td></tr>
<tr class="memdesc:a0f3ffa92b4eaffde5de4c0393bf662d3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Find all files in a directory by name.  <br /></td></tr>
<tr class="separator:a0f3ffa92b4eaffde5de4c0393bf662d3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa4aa18393e23d0022051e5ee9f5e4ff6" id="r_aa4aa18393e23d0022051e5ee9f5e4ff6"><td class="memItemLeft" align="right" valign="top"><a class="el" href="filetype_8h.html#a8827b47b58e5d520b41cb950d8fdea7c">filevec</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#aa4aa18393e23d0022051e5ee9f5e4ff6">cutl::find_files_by_extension</a> (const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;dirpath, const std::string &amp;extension, bool recursive=false)</td></tr>
<tr class="memdesc:aa4aa18393e23d0022051e5ee9f5e4ff6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Find all files in a directory by extension.  <br /></td></tr>
<tr class="separator:aa4aa18393e23d0022051e5ee9f5e4ff6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a001077c7cc1071c8871ca7b338face04" id="r_a001077c7cc1071c8871ca7b338face04"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a001077c7cc1071c8871ca7b338face04">cutl::copyfile</a> (const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;srcpath, const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;dstpath, bool attributes=false)</td></tr>
<tr class="memdesc:a001077c7cc1071c8871ca7b338face04"><td class="mdescLeft">&#160;</td><td class="mdescRight">Copy a file or symbolic link(shortcut on windows).  <br /></td></tr>
<tr class="separator:a001077c7cc1071c8871ca7b338face04"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afa2d5fd4752b0b76ffcf5b3307800a9c" id="r_afa2d5fd4752b0b76ffcf5b3307800a9c"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#afa2d5fd4752b0b76ffcf5b3307800a9c">cutl::copydir</a> (const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;srcdir, const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;dstdir)</td></tr>
<tr class="memdesc:afa2d5fd4752b0b76ffcf5b3307800a9c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Copy a directory recursively.  <br /></td></tr>
<tr class="separator:afa2d5fd4752b0b76ffcf5b3307800a9c"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>The functions and classes about filesystem, such as file and directory operations. </p>
<dl class="section copyright"><dt>Copyright</dt><dd>Copyright (c) 2024, Spencer.Luo. All Rights Reserved.</dd></dl>
<p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at </p><pre class="fragment">  http://www.apache.org/licenses/LICENSE-2.0
</pre><p> Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations.</p>
<dl class="section author"><dt>Author</dt><dd>spencer.luo </dd></dl>
<dl class="section date"><dt>Date</dt><dd>2024-05-13 </dd></dl>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="afa2d5fd4752b0b76ffcf5b3307800a9c" name="afa2d5fd4752b0b76ffcf5b3307800a9c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#afa2d5fd4752b0b76ffcf5b3307800a9c">&#9670;&#160;</a></span>copydir()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool cutl::copydir </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;</td>          <td class="paramname"><span class="paramname"><em>srcdir</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;</td>          <td class="paramname"><span class="paramname"><em>dstdir</em></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Copy a directory recursively. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">srcdir</td><td>the filepath of the source directory to be copied </td></tr>
    <tr><td class="paramname">dstdir</td><td>the filepath of the destination directory to be copied to </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if the directory is copied successfully, false otherwise. </dd></dl>
<dl class="section note"><dt>Note</dt><dd>If the destination directory already exists, it will be overwritten. </dd></dl>

</div>
</div>
<a id="a001077c7cc1071c8871ca7b338face04" name="a001077c7cc1071c8871ca7b338face04"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a001077c7cc1071c8871ca7b338face04">&#9670;&#160;</a></span>copyfile()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool cutl::copyfile </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;</td>          <td class="paramname"><span class="paramname"><em>srcpath</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;</td>          <td class="paramname"><span class="paramname"><em>dstpath</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool</td>          <td class="paramname"><span class="paramname"><em>attributes</em><span class="paramdefsep"> = </span><span class="paramdefval">false</span></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Copy a file or symbolic link(shortcut on windows). </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">srcpath</td><td>the filepath of the source file or symbolic link to be copied </td></tr>
    <tr><td class="paramname">dstpath</td><td>the filepath of the destination file or symbolic link to be copied to </td></tr>
    <tr><td class="paramname">attributes</td><td>whether to copy the file attributes, default is false. If true, means copy the file attributes, like the 'cp -p' command. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if the file or symbolic link is copied successfully, false otherwise. </dd></dl>
<dl class="section note"><dt>Note</dt><dd>If the destination file or directory already exists, it will be overwritten. </dd></dl>
<dl class="section return"><dt>Returns</dt><dd>false </dd></dl>

</div>
</div>
<a id="add3d8ef4215ce8d54c9dbe18dd35c82b" name="add3d8ef4215ce8d54c9dbe18dd35c82b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#add3d8ef4215ce8d54c9dbe18dd35c82b">&#9670;&#160;</a></span>createdir()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool cutl::createdir </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;</td>          <td class="paramname"><span class="paramname"><em>path</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool</td>          <td class="paramname"><span class="paramname"><em>recursive</em><span class="paramdefsep"> = </span><span class="paramdefval">false</span></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Create a new directory. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">path</td><td>the filepath of the new directory to be created </td></tr>
    <tr><td class="paramname">recursive</td><td>whether to create parent directories, default is false. If true, means create parent directories if not exist, like the 'mkdir -p' command. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if the directory is created successfully, false otherwise. </dd></dl>

</div>
</div>
<a id="a1e27df14bf44381e7e0a20e4c573d4f5" name="a1e27df14bf44381e7e0a20e4c573d4f5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a1e27df14bf44381e7e0a20e4c573d4f5">&#9670;&#160;</a></span>createfile()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool cutl::createfile </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;</td>          <td class="paramname"><span class="paramname"><em>path</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Create a new file. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">path</td><td>the filepath of the new file to be created </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if the file is created successfully, false otherwise. </dd></dl>

</div>
</div>
<a id="a08d521298f87d3470d3163928d3cb1f1" name="a08d521298f87d3470d3163928d3cb1f1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a08d521298f87d3470d3163928d3cb1f1">&#9670;&#160;</a></span>createlink()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool cutl::createlink </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;</td>          <td class="paramname"><span class="paramname"><em>referenece</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;</td>          <td class="paramname"><span class="paramname"><em>filepath</em></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Create a symbolic link or shortcut. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">referenece</td><td>the real path referenced by the symbolic link or shortcut </td></tr>
    <tr><td class="paramname">filepath</td><td>the filepath of the symbolic link or shortcut to be created </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if the symbolic link or shortcut is created successfully, false otherwise. </dd></dl>

</div>
</div>
<a id="add5974dfd24e73d6ea0384d986e03291" name="add5974dfd24e73d6ea0384d986e03291"></a>
<h2 class="memtitle"><span class="permalink"><a href="#add5974dfd24e73d6ea0384d986e03291">&#9670;&#160;</a></span>dirsize()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint64_t cutl::dirsize </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;</td>          <td class="paramname"><span class="paramname"><em>dirpath</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get the size of a directory, include all files and subdirectories. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">dirpath</td><td>the filepath of the directory to be checked </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the total size of the directory in bytes </dd></dl>

</div>
</div>
<a id="ae0b32140037ee8ad3eed3f916aca6121" name="ae0b32140037ee8ad3eed3f916aca6121"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae0b32140037ee8ad3eed3f916aca6121">&#9670;&#160;</a></span>filesize()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint64_t cutl::filesize </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;</td>          <td class="paramname"><span class="paramname"><em>filepath</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool</td>          <td class="paramname"><span class="paramname"><em>link_target</em><span class="paramdefsep"> = </span><span class="paramdefval">false</span></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get the size of a file. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">filepath</td><td>the filepath of the file to be checked</td></tr>
    <tr><td class="paramname">link_target</td><td>whether to get the size of the file pointed by symbolic link, default is false. If link_target is true, the function will get the size of the file pointed by symbolic link, not the symbolic link itself.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>link_target parameter only works on Unix-like systems, not support on Windows.</dd></dl>
<dl class="section return"><dt>Returns</dt><dd>file size in bytes </dd></dl>

</div>
</div>
<a id="ab248798acf21f8ce5735738f0882a91b" name="ab248798acf21f8ce5735738f0882a91b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab248798acf21f8ce5735738f0882a91b">&#9670;&#160;</a></span>filetype_flag()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">std::string cutl::filetype_flag </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="filetype_8h.html#a9d3ee53b2774c37cc5a17766507de28c">filetype</a></td>          <td class="paramname"><span class="paramname"><em>type</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Get the file type flag string. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">type</td><td>file type </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the flag string of the file type </dd></dl>

</div>
</div>
<a id="a0f3ffa92b4eaffde5de4c0393bf662d3" name="a0f3ffa92b4eaffde5de4c0393bf662d3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0f3ffa92b4eaffde5de4c0393bf662d3">&#9670;&#160;</a></span>find_files()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">filevec cutl::find_files </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;</td>          <td class="paramname"><span class="paramname"><em>dirpath</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const std::string &amp;</td>          <td class="paramname"><span class="paramname"><em>name</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool</td>          <td class="paramname"><span class="paramname"><em>recursive</em><span class="paramdefsep"> = </span><span class="paramdefval">false</span></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Find all files in a directory by name. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">dirpath</td><td>the filepath of the directory to be searched </td></tr>
    <tr><td class="paramname">name</td><td>the name of the file to be found, substring match is supported. </td></tr>
    <tr><td class="paramname">recursive</td><td>whether to search the whole directory recursively, default is false. If true, means search the whole directory recursively, like the 'find' command. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>filevec the vector of file_entity, filepaths in the directory. </dd></dl>

</div>
</div>
<a id="aa4aa18393e23d0022051e5ee9f5e4ff6" name="aa4aa18393e23d0022051e5ee9f5e4ff6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa4aa18393e23d0022051e5ee9f5e4ff6">&#9670;&#160;</a></span>find_files_by_extension()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">filevec cutl::find_files_by_extension </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;</td>          <td class="paramname"><span class="paramname"><em>dirpath</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const std::string &amp;</td>          <td class="paramname"><span class="paramname"><em>extension</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool</td>          <td class="paramname"><span class="paramname"><em>recursive</em><span class="paramdefsep"> = </span><span class="paramdefval">false</span></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Find all files in a directory by extension. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">dirpath</td><td>the filepath of the directory to be searched </td></tr>
    <tr><td class="paramname">extension</td><td>the extension of the file to be found, with dot, like ".txt". </td></tr>
    <tr><td class="paramname">recursive</td><td>whether to search the whole directory recursively, default is false. If true, means search the whole directory recursively, like the 'find' command. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>filevec the vector of file_entity, filepaths in the directory. </dd></dl>

</div>
</div>
<a id="aa4f744aa8a74118855fab1240f556c50" name="aa4f744aa8a74118855fab1240f556c50"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa4f744aa8a74118855fab1240f556c50">&#9670;&#160;</a></span>list_files()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">filevec cutl::list_files </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;</td>          <td class="paramname"><span class="paramname"><em>dirpath</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="filetype_8h.html#a9d3ee53b2774c37cc5a17766507de28c">filetype</a></td>          <td class="paramname"><span class="paramname"><em>type</em><span class="paramdefsep"> = </span><span class="paramdefval"><a class="el" href="filetype_8h.html#a9d3ee53b2774c37cc5a17766507de28ca2f81ea5535f9ec58b162200d3c6a29c6">filetype::all</a></span>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool</td>          <td class="paramname"><span class="paramname"><em>recursive</em><span class="paramdefsep"> = </span><span class="paramdefval">false</span></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>List all files in a directory. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">dirpath</td><td>the filepath of the directory to be listed </td></tr>
    <tr><td class="paramname">type</td><td>file type to be listed, default is all types. </td></tr>
    <tr><td class="paramname">recursive</td><td>whether to list the whole directory recursively, default is false. If true, means list the whole directory recursively, like the 'ls -R' command. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>filevec the vector of file_entity, filepaths in the directory. </dd></dl>

</div>
</div>
<a id="a27c4f2c12172b95c3f64090e431e0393" name="a27c4f2c12172b95c3f64090e431e0393"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a27c4f2c12172b95c3f64090e431e0393">&#9670;&#160;</a></span>readtext()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">std::string cutl::readtext </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;</td>          <td class="paramname"><span class="paramname"><em>path</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint64_t</td>          <td class="paramname"><span class="paramname"><em>max_read_size</em><span class="paramdefsep"> = </span><span class="paramdefval">4096</span></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Read the text content of a file. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">path</td><td>the filepath of the file to be read </td></tr>
    <tr><td class="paramname">max_read_size</td><td>the maximum size to be read, default is 4096 bytes.</td></tr>
  </table>
  </dd>
</dl>
<p>If the file size is larger than max_read_size, only the first max_read_size bytes will be read. otherwise, the whole file will be read.</p>
<dl class="section return"><dt>Returns</dt><dd>text content of the file </dd></dl>

</div>
</div>
<a id="a59de688713570479a87f534309f7ec6a" name="a59de688713570479a87f534309f7ec6a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a59de688713570479a87f534309f7ec6a">&#9670;&#160;</a></span>removedir()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool cutl::removedir </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;</td>          <td class="paramname"><span class="paramname"><em>path</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool</td>          <td class="paramname"><span class="paramname"><em>recursive</em><span class="paramdefsep"> = </span><span class="paramdefval">false</span></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Remove a directory. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">path</td><td>the filepath of the directory to be removed </td></tr>
    <tr><td class="paramname">recursive</td><td>whether to remove the whole directory recursively, default is false. If true, means remove the whole directory recursively, like the 'rm -rf' command. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if the directory is removed successfully, false otherwise. </dd></dl>

</div>
</div>
<a id="ab5971fce037518ec1d89532511e84cdf" name="ab5971fce037518ec1d89532511e84cdf"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab5971fce037518ec1d89532511e84cdf">&#9670;&#160;</a></span>removefile()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool cutl::removefile </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;</td>          <td class="paramname"><span class="paramname"><em>path</em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Remove a regular file or symbolic link(shortcut on windows). </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">path</td><td>the filepath of the file or symbolic link to be removed </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if the file or symbolic link is removed successfully, false otherwise. </dd></dl>

</div>
</div>
<a id="afce142cfc976c83b8236dfdb2edec314" name="afce142cfc976c83b8236dfdb2edec314"></a>
<h2 class="memtitle"><span class="permalink"><a href="#afce142cfc976c83b8236dfdb2edec314">&#9670;&#160;</a></span>writetext()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool cutl::writetext </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classcutl_1_1filepath.html">filepath</a> &amp;</td>          <td class="paramname"><span class="paramname"><em>path</em>, </span></td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const std::string &amp;</td>          <td class="paramname"><span class="paramname"><em>content</em></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Write the text content to a file. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">path</td><td>the filepath of the file to be written </td></tr>
    <tr><td class="paramname">content</td><td>text content to be written to the file </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if the content is written successfully, false otherwise. </dd></dl>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.10.0
</small></address>
</body>
</html>
